package com.caochenlei.graph;

import java.util.Stack;

public class DepthFirstOrderTest {
    public static void main(String[] args) {
        Digraph D = new Digraph(6);
        D.addEdge(0, 2);
        D.addEdge(2, 4);
        D.addEdge(4, 5);
        D.addEdge(0, 3);
        D.addEdge(3, 4);
        D.addEdge(1, 3);

        DepthFirstOrder order = new DepthFirstOrder(D);
        Stack<Integer> stack = order.reversePost();
        while (!stack.isEmpty()) {
            System.out.println(stack.pop());
        }
    }
}
